﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EQual.MainModule.Documents.Forms
{
    /// <summary>
    /// Controlls the modification of a Form .if is modifided is saved .if is filled is saved as 
    /// a new Record 
    /// </summary>
    public class RecordPresenter
    {
        public object ActiveItem { get; set; }

        public EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<DataAccesLayer.Document>> DocumentSavedHandler()
        {
            return delegate(object sender, Microsoft.Practices.Composite.Events.DataEventArgs<DataAccesLayer.Document> e)
            {
                DisplayDocumentSaveDialog();
            };
        }

        public EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> UpdateDocument()
        {
            return delegate(object s, Microsoft.Practices.Composite.Events.DataEventArgs<object> e)
            {
                DisplayVersionDialog();
            };
        }

        public EventHandler<Microsoft.Practices.Composite.Events.DataEventArgs<object>> UpdateFormVersion()
        {
            return delegate(object s, Microsoft.Practices.Composite.Events.DataEventArgs<object> e)
            {

            };
        }

        protected virtual void RequestNewVersionUpdate(object version)
        {
           
        }

        protected virtual void DisplayVersionDialog()
        {
            Views.VersionSaveDialog VersionSaveDialog = new Views.VersionSaveDialog();
            VersionSaveDialog.OnVersionUpdated += UpdateFormVersion();
            VersionSaveDialog.ShowDialog();
        }

        protected virtual void DisplayDocumentSaveDialog()
        {
            Views.DocumentSaveDialog DocumentSaveDialog = new Views.DocumentSaveDialog();
            DocumentSaveDialog.OnDocumentUpdated += UpdateDocument();
            DocumentSaveDialog.ShowDialog();
        }


    }
}
